/*
 * GuildFraktionInfo - list the reputation of all member of a guild
 * Copyright (C) [2012 - 2013] [www.marantis.de]
 * 
 * This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public 
 * License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later 
 * version.
 * 
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied 
 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License along with this program; if not, 
 * see <http://www.gnu.org/licenses/>.
 */
package de.marantis.app.wow.gfi;

import java.io.File;
import java.net.URL;
import java.util.ArrayList;

import de.marantis.app.wow.gfi.beans.ConfigBean;
import de.marantis.app.wow.gfi.control.MainConsoleController;
import de.marantis.app.wow.gfi.helper.ConfigHelper;

import org.apache.log4j.BasicConfigurator;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;

public class Main {
    
    public final static String version = "1.2.1";
    
    private final static Logger log = Logger.getLogger(Main.class);
    
    public static void main(String[] args) {
        try {

            //*** min/max is 1 arg ***
           // if (args == null || args.length != 1){
            //    ConfigHelper.printHelp();
             //   return;
            //}
            
            /* 
             * set the log4j config to a minimal default config (console).
             * 
             * later we load the final log4j-config from the gfi-config.properties.
             * 
             * with this solution we have a minimal log4j config if there is an exception
             * in the time we try to read the gfi-config file and init. the final log4j 
             * config with it.
             */
        	 	BasicConfigurator.configure();
            Logger.getRootLogger().setLevel(Level.INFO);
            
            //*** load the config file ***
           ConfigBean config = new ConfigBean();
           config.setArmoryUrl(new URL("http://eu.battle.net/wow/de/guild/onyxia/Innocentia/roster"));
           ArrayList<String> array=new ArrayList();
           array.add("Gildenmeister");
           array.add("Member");
           config.setTestMode(false);;
           config.setGuildLevelNames(array);
          
           config.setJsonExportFile(new File("analyse.json"));
           config.setConsoleMode(false);
           
            //boolean okFlag = ConfigHelper.checkArgs(args, config);
            //*** run the scanner ***
            
             MainConsoleController ctrl = new MainConsoleController(config);
         
             ctrl.scanArmory();
         
             
             //System.out.println(ctrl.getChars2().toString());
             
             
            
            
            //*** finish this application ***
            Runtime.getRuntime().exit(0);
            
        } catch (Exception e) {
        	e.printStackTrace();
            if (log == null) {
                e.printStackTrace();
            } else {
                log.error(e);
            }
            
            Runtime.getRuntime().exit(1);
        }
    }
}
